﻿//GB/Z 29014.3 ISYC 309-04f-外径切槽和切断用可转位刀片车刀

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class class_ISYC_309_04f
    {
        public static void ISYC_309_F95f(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //基本参数-------------------------------------------------------------------------------------------------
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //赋值参数--------------------------------------------------------------------------------------------------
            /*double scale = 1;
            double OAL = 30.69;
            double CDX = 5.3;
            double H = 7.07;
            double HF = 5.81;
            double LPR = 13.05;
            double LF = 31.11;
            double WTA = 2.09;*/

            double scale = Convert.ToDouble(data["scale"]);
            double OAL = Convert.ToDouble(data["oal"]);
            double CDX = Convert.ToDouble(data["cdx"]);
            double H = Convert.ToDouble(data["h"]);
            double HF = Convert.ToDouble(data["hf"]);
            double LPR = Convert.ToDouble(data["lpr"]);
            double LF = Convert.ToDouble(data["lf"]);
            double WTA = Convert.ToDouble(data["wta"]);

            //点---------------------------------------------------------------------------------------------
            //第一部分
            //轮廓
            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(v1.X + (OAL - CDX), v1.Y);
            Vector2 v3 = new Vector2(v2.X + (4.15 / 30.69) * OAL, v2.Y - (1.1 / 7.07) * H);
            Vector2 v4 = new Vector2(v3.X + (1.12 / 30.69) * OAL, v3.Y - (0.96 / 7.07) * H);
            Vector2 v5 = new Vector2(v4.X - (0.23 / 30.69) * OAL, v4.Y - (0.79 / 7.07) * H);
            Vector2 v6 = new Vector2(v5.X + (0.24 / 30.69) * OAL, v5.Y - (0.49 / 7.07) * H);
            Vector2 v7 = new Vector2(v6.X, v1.Y - H);
            Vector2 v8 = new Vector2(v7.X - (25.49 / 30.69) * OAL, v7.Y);
            Vector2 v9 = new Vector2(v8.X - (4.02 / 30.69) * OAL, v8.Y + (1 / 7.07) * H);
            Vector2 v10 = new Vector2(v9.X, v9.Y + (0.25 / 7.07) * H);
            Vector2 v11 = new Vector2(v10.X + (1.8 / 30.69) * OAL, v10.Y + (1.04 / 7.07) * H);
            Vector2 v12 = new Vector2(v11.X, v11.Y + (1.4 / 7.07) * H);
            Vector2 v13 = new Vector2(v1.X, v1.Y - (4.42 / 7.07) * H);
            Vector2 v14 = new Vector2(v3.X - (1.85 / 30.69) * OAL, v3.Y - (2.71 / 7.07) * H);
            Vector2 v15 = new Vector2(v14.X + (0.15 / 5.3) * CDX, v14.Y + (1.39 / 7.07) * H);
            Vector2 v16 = new Vector2(v15.X + (1.9 / 5.3) * CDX, v15.Y + (1.16 / 7.07) * H);
            Vector2 v17 = new Vector2(v16.X + (0.95 / 5.3) * CDX, v16.Y);
            Vector2 v18 = new Vector2(v2.X - (6.28 / 30.69) * OAL, v2.Y + (2.87 / 7.07) * H);
            Vector2 v19 = new Vector2(v18.X, v18.Y - (13.72 / 7.07) * H);
            Vector2 v20 = fun.Inters(v13, fun.Polar(v13, -90 * pi / 180, OAL), v8, fun.Polar(v8, pi, OAL));
            Vector2 v21 = new Vector2(v2.X - (7.31 / 30.69) * OAL, v2.Y - (1.13 / 7.07) * H);

            //第二部分
            Vector2 v22 = new Vector2(v1.X, v20.Y - (14.71 / 7.07) * H);
            Vector2 v23 = new Vector2(v1.X + (31.11 / 30.69) * OAL, v22.Y);
            Vector2 v24 = new Vector2(v23.X, v23.Y - (0.71 / 7.07) * H);
            Vector2 v25 = new Vector2(v22.X, v24.Y);
            Vector2 v26 = new Vector2(v22.X + (25.63 / 30.69) * OAL, v22.Y);
            Vector2 v27 = new Vector2(v26.X, v24.Y);
            Vector2 v28 = new Vector2(v26.X + (4.22 / 30.69) * OAL, v23.Y);
            Vector2 v29 = new Vector2(v28.X, v24.Y);
            Vector2 v30 = new Vector2(v28.X + (0.65 / 30.69) * OAL, v23.Y);
            Vector2 v31 = new Vector2(v30.X, v24.Y);
            Vector2 v32 = new Vector2(v24.X - LPR, v24.Y);
            Vector2 v33 = new Vector2(v32.X - (4.55 / 30.69) * OAL, v32.Y + (2.53 / 7.07) * H);
            Vector2 v34 = new Vector2(v33.X + (18.75 / 30.69) * OAL, v33.Y);
            Vector2 v35 = new Vector2(v34.X, v34.Y - (6.82 / 7.07) * H);
            Vector2 v36 = new Vector2(v33.X, v35.Y);
            Vector2 v37 = new Vector2(v35.X + (15.43 / 30.69) * OAL, v35.Y - (3.09 / 7.07) * H);
            Vector2 v38 = new Vector2(v33.X + (9.09 / 30.69) * OAL, v33.Y + (0.91 / 7.07) * H);

            //第三部分
            Vector2 v39 = new Vector2(v20.X - (20.68 / 30.69) * OAL, v20.Y);
            Vector2 v40 = new Vector2(v39.X + (0.67 / 30.69) * OAL, v20.Y);
            Vector2 v41 = new Vector2(v40.X, v40.Y + ((6.91 / 7.07) * H));
            Vector2 v42 = new Vector2(v39.X, v41.Y);
            Vector2 v43 = new Vector2(v39.X - (1.28 / 30.69) * OAL, v39.Y + ((1.46 / 7.07) * H));
            Vector2 v44 = new Vector2(v43.X + (3.1 / 30.69) * OAL, v43.Y);
            Vector2 v45 = new Vector2(v44.X, v44.Y - ((2.58 / 7.07) * H));
            Vector2 v46 = new Vector2(v43.X, v45.Y);
            Vector2 v47 = new Vector2(v42.X - (8.99 / 30.69) * OAL, v42.Y + ((7.39 / 7.07) * H));
            Vector2 v48 = new Vector2(v47.X + (15.15 / 30.69) * OAL, v47.Y);
            Vector2 v49 = new Vector2(v48.X, v48.Y - ((19.25 / 7.07) * H));
            Vector2 v50 = new Vector2(v47.X, v49.Y);
            Vector2 v51 = new Vector2(v47.X + (6.25 / 30.69) * OAL, v47.Y + (1.01 / 7.07) * H);
            Vector2 v52 = new Vector2(v46.X - (3.76 / 30.69) * OAL, v46.Y - (2.88 / 7.07) * H);
            Vector2 v53 = new Vector2(v42.X, v42.Y - (0.97 / 7.07) * H);

            //第四部分
            Vector2 v54 = new Vector2(v50.X + (6.21 / 30.69) * OAL, v50.Y - (10.79 / 7.07) * H);
            Vector2 v55 = new Vector2(v54.X, v54.Y - (5.66 / 7.07) * H);
            Vector2 v56 = new Vector2(v55.X + (1.05 / 30.69) * OAL, v55.Y - (0.6 / 7.07) * H);
            Vector2 v57 = new Vector2(v56.X + (1.05 / 30.69) * OAL, v55.Y);
            Vector2 v58 = new Vector2(v57.X, v54.Y);
            Vector2 v59 = fun.Inters(v55, fun.Polar(v55, -90 * pi / 180, OAL), v56, fun.Polar(v56, -150 * pi / 180, OAL));
            Vector2 v60 = new Vector2(v54.X - (5.55 / 30.69) * OAL, v54.Y + (4.14 / 7.07) * H);
            Vector2 v61 = new Vector2(v60.X + (13.54 / 30.69) * OAL, v60.Y);
            Vector2 v62 = new Vector2(v61.X, v61.Y - (18.16 / 7.07) * H);
            Vector2 v63 = new Vector2(v60.X, v62.Y);
            Vector2 v64 = new Vector2(v60.X + (6.11 / 30.69) * OAL, v60.Y + (0.74 / 7.07) * H);

            //第五部分
            Vector2 v65 = new Vector2(v25.X - (2.21 / 30.69) * OAL, v25.Y - (30.16 / 7.07) * H);
            Vector2 v66 = new Vector2(v65.X + (23.36 / 30.69) * OAL, v65.Y);
            Vector2 v67 = new Vector2(v66.X, v65.Y + (0.18 / 7.07) * H);
            Vector2 v68 = new Vector2(v67.X + (1.36 / 30.69) * OAL, v67.Y);
            Vector2 v69 = new Vector2(v68.X + (0.14 / 30.69) * OAL, v68.Y + (0.14 / 7.07) * H);
            Vector2 v70 = new Vector2(v69.X + (1.52 / 30.69) * OAL, v69.Y);
            Vector2 v71 = new Vector2(v70.X, v70.Y - WTA);
            Vector2 v72 = new Vector2(v71.X - (0.21 / 30.69) * OAL, v71.Y);
            Vector2 v73 = new Vector2(v72.X, v72.Y - (0.22 / 7.07) * H);
            Vector2 v74 = new Vector2(v73.X - (1.28 / 30.69) * OAL, v73.Y);
            Vector2 v75 = new Vector2(v72.X - (1.52 / 30.69) * OAL, v72.Y);
            Vector2 v76 = new Vector2(v66.X, v71.Y);
            Vector2 v77 = new Vector2(v76.X, v76.Y + (0.06 / 7.07) * H);
            Vector2 v78 = new Vector2(v65.X, v77.Y);
            Vector2 v79 = new Vector2(v65.X + (13.18 / 30.69) * OAL, v65.Y);
            Vector2 v81 = new Vector2(v65.X + (13.18 / 30.69) * OAL, v77.Y);
            Vector2 v82 = new Vector2(v78.X + (4.43 / 30.69) * OAL, v78.Y);
            Vector2 v83 = new Vector2(v65.X - (4.11 / 30.69) * OAL, v65.Y + (6.75 / 7.07) * H);
            Vector2 v84 = new Vector2(v83.X + (42.71 / 30.69) * OAL, v83.Y);
            Vector2 v85 = new Vector2(v84.X, v84.Y - (17.97 / 7.07) * H);
            Vector2 v86 = new Vector2(v83.X, v85.Y);
            Vector2 v87 = new Vector2(v83.X + (21.06 / 30.69) * OAL, v83.Y + (0.63 / 7.07) * H);
            Vector2 v88 = new Vector2(v70.X, v70.Y - fun.CalDistance(v70, v71) / 2.0);

            //作图部分-----------------------------------------------------------------------
            //第一部分
            //轮廓
            LwPolyline polyline1 = new LwPolyline();
            polyline1.Vertexes.Add(new LwPolylineVertex(v1));
            polyline1.Vertexes.Add(new LwPolylineVertex(v2));
            polyline1.Vertexes.Add(new LwPolylineVertex(v3));//1
            polyline1.Vertexes.Add(new LwPolylineVertex(v4));//2
            polyline1.Vertexes.Add(new LwPolylineVertex(v5));
            polyline1.Vertexes.Add(new LwPolylineVertex(v6));
            polyline1.Vertexes.Add(new LwPolylineVertex(v7));
            polyline1.Vertexes.Add(new LwPolylineVertex(v8));
            polyline1.Vertexes.Add(new LwPolylineVertex(v9));//7
            polyline1.Vertexes.Add(new LwPolylineVertex(v10));
            polyline1.Vertexes.Add(new LwPolylineVertex(v11));
            polyline1.Vertexes.Add(new LwPolylineVertex(v12));
            polyline1.Vertexes.Add(new LwPolylineVertex(v13));
            polyline1.Vertexes.Add(new LwPolylineVertex(v1));
            polyline1.Vertexes[1].Bulge = Math.Tan(47 * pi / 180 / 4);
            polyline1.Vertexes[2].Bulge = Math.Tan(76 * pi / 180 / 4);
            polyline1.Vertexes[7].Bulge = Math.Tan(55 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.3, contour);

            LwPolyline polyline2 = new LwPolyline();
            polyline2.Vertexes.Add(new LwPolylineVertex(v14));
            polyline2.Vertexes.Add(new LwPolylineVertex(v15));
            polyline2.Vertexes.Add(new LwPolylineVertex(v16));
            polyline2.Vertexes.Add(new LwPolylineVertex(v17));
            polyline2.Vertexes.Add(new LwPolylineVertex(v4));
            polyline2.Vertexes.Add(new LwPolylineVertex(v5));
            polyline2.Vertexes.Add(new LwPolylineVertex(v14));
            fun.PolyFill(dxf, polyline2, 0.3, contour);

            //虚线
            /*LwPolyline polyline3 = new LwPolyline();
            polyline3.Vertexes.Add(new LwPolylineVertex(v18));
            polyline3.Vertexes.Add(new LwPolylineVertex(v19));
            polyline3.Linetype = Linetype.Dashed;
            polyline3.LinetypeScale = 5;
            polyline3.Layer = refin;
            dxf.AddEntity(polyline3);

            Circle circle1 = new Circle(v17, fun.CalDistance(v17, v2));
            circle1.Linetype = Linetype.Dashed;
            circle1.LinetypeScale = 5;
            circle1.Layer = refin;
            dxf.AddEntity(circle1);*/

            //第二部分
            //轮廓
            LwPolyline polyline4 = new LwPolyline();
            polyline4.Vertexes.Add(new LwPolylineVertex(v22));
            polyline4.Vertexes.Add(new LwPolylineVertex(v23));
            polyline4.Vertexes.Add(new LwPolylineVertex(v24));
            polyline4.Vertexes.Add(new LwPolylineVertex(v25));
            polyline4.Vertexes.Add(new LwPolylineVertex(v22));
            fun.PolyFill(dxf, polyline4, 0.3, contour);

            LwPolyline polyline5 = new LwPolyline();
            polyline5.Vertexes.Add(new LwPolylineVertex(v26));
            polyline5.Vertexes.Add(new LwPolylineVertex(v27));
            fun.PolyFill(dxf, polyline5, 0.3, contour);

            LwPolyline polyline6 = new LwPolyline();
            polyline6.Vertexes.Add(new LwPolylineVertex(v28));
            polyline6.Vertexes.Add(new LwPolylineVertex(v29));
            fun.PolyFill(dxf, polyline6, 0.3, contour);

            LwPolyline polyline7 = new LwPolyline();
            polyline7.Vertexes.Add(new LwPolylineVertex(v30));
            polyline7.Vertexes.Add(new LwPolylineVertex(v31));
            fun.PolyFill(dxf, polyline7, 0.3, contour);

            //虚线
            /*LwPolyline polyline8 = new LwPolyline();
            polyline8.Vertexes.Add(new LwPolylineVertex(v33));
            polyline8.Vertexes.Add(new LwPolylineVertex(v34));
            polyline8.Vertexes.Add(new LwPolylineVertex(v35));
            polyline8.Vertexes.Add(new LwPolylineVertex(v36));
            polyline8.Vertexes.Add(new LwPolylineVertex(v33));
            polyline8.Linetype = Linetype.Dashed;
            polyline8.LinetypeScale = 5;
            polyline8.Layer = refin;
            dxf.AddEntity(polyline8);*/

            //第三部分
            //轮廓
            /*LwPolyline polyline9 = new LwPolyline();
            polyline9.Vertexes.Add(new LwPolylineVertex(v39));
            polyline9.Vertexes.Add(new LwPolylineVertex(v40));
            polyline9.Vertexes.Add(new LwPolylineVertex(v41));
            polyline9.Vertexes.Add(new LwPolylineVertex(v42));//2
            polyline9.Vertexes.Add(new LwPolylineVertex(v39));
            polyline9.Vertexes[2].Bulge = Math.Tan(180 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline9, 0.3, contour);

            //虚线
            LwPolyline polyline10 = new LwPolyline();
            polyline10.Vertexes.Add(new LwPolylineVertex(v43));
            polyline10.Vertexes.Add(new LwPolylineVertex(v44));
            polyline10.Vertexes.Add(new LwPolylineVertex(v45));
            polyline10.Vertexes.Add(new LwPolylineVertex(v46));
            polyline10.Vertexes.Add(new LwPolylineVertex(v43));
            polyline10.Linetype = Linetype.Dashed;
            polyline10.LinetypeScale = 5;
            polyline10.Layer = refin;
            dxf.AddEntity(polyline10);

            LwPolyline polyline11 = new LwPolyline();
            polyline11.Vertexes.Add(new LwPolylineVertex(v47));
            polyline11.Vertexes.Add(new LwPolylineVertex(v48));
            polyline11.Vertexes.Add(new LwPolylineVertex(v49));
            polyline11.Vertexes.Add(new LwPolylineVertex(v50));
            polyline11.Vertexes.Add(new LwPolylineVertex(v47));
            polyline11.Linetype = Linetype.Dashed;
            polyline11.LinetypeScale = 5;
            polyline11.Layer = refin;
            dxf.AddEntity(polyline11);

            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v39));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v40));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v42));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v39));
            hatchpoly1.Vertexes[2].Bulge = Math.Tan(180 * pi / 180 / 4);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);

            //第四部分
            //轮廓
            LwPolyline polyline12 = new LwPolyline();
            polyline12.Vertexes.Add(new LwPolylineVertex(v54));
            polyline12.Vertexes.Add(new LwPolylineVertex(v55));
            polyline12.Vertexes.Add(new LwPolylineVertex(v56));
            polyline12.Vertexes.Add(new LwPolylineVertex(v57));
            polyline12.Vertexes.Add(new LwPolylineVertex(v58));
            fun.PolyFill(dxf, polyline12, 0.3, contour);

            //虚线
            LwPolyline polyline13 = new LwPolyline();
            polyline13.Vertexes.Add(new LwPolylineVertex(v60));
            polyline13.Vertexes.Add(new LwPolylineVertex(v61));
            polyline13.Vertexes.Add(new LwPolylineVertex(v62));
            polyline13.Vertexes.Add(new LwPolylineVertex(v63));
            polyline13.Vertexes.Add(new LwPolylineVertex(v60));
            polyline13.Linetype = Linetype.Dashed;
            polyline13.LinetypeScale = 5;
            polyline13.Layer = refin;
            dxf.AddEntity(polyline13);

            //填充
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v54));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v57));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v58));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v54));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            Arc[] harc3 = new Arc[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
                if (htype3[i] == "Arc")
                {
                    harc3[i] = (Arc)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype3, hnumst3, 45, 5, hline3, harc3, hatching);

            //第五部分
            //轮廓
            LwPolyline polyline14 = new LwPolyline();
            polyline14.Vertexes.Add(new LwPolylineVertex(v65));
            polyline14.Vertexes.Add(new LwPolylineVertex(v66));
            polyline14.Vertexes.Add(new LwPolylineVertex(v67));
            polyline14.Vertexes.Add(new LwPolylineVertex(v68));
            polyline14.Vertexes.Add(new LwPolylineVertex(v69));
            polyline14.Vertexes.Add(new LwPolylineVertex(v70));
            polyline14.Vertexes.Add(new LwPolylineVertex(v71));
            polyline14.Vertexes.Add(new LwPolylineVertex(v76));
            polyline14.Vertexes.Add(new LwPolylineVertex(v77));
            polyline14.Vertexes.Add(new LwPolylineVertex(v78));
            fun.PolyFill(dxf, polyline14, 0.3, contour);

            LwPolyline polyline15 = new LwPolyline();
            polyline15.Vertexes.Add(new LwPolylineVertex(v79));
            polyline15.Vertexes.Add(new LwPolylineVertex(v81));//0
            polyline15.Vertexes[0].Bulge = Math.Tan(62 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline15, 0.3, contour);

            LwPolyline polyline16 = new LwPolyline();
            polyline16.Vertexes.Add(new LwPolylineVertex(v66));
            polyline16.Vertexes.Add(new LwPolylineVertex(v77));
            fun.PolyFill(dxf, polyline16, 0.3, contour);

            LwPolyline polyline17 = new LwPolyline();
            polyline17.Vertexes.Add(new LwPolylineVertex(v72));
            polyline17.Vertexes.Add(new LwPolylineVertex(v73));
            polyline17.Vertexes.Add(new LwPolylineVertex(v74));
            polyline17.Vertexes.Add(new LwPolylineVertex(v75));
            fun.PolyFill(dxf, polyline17, 0.3, contour);

            LwPolyline polyline18 = new LwPolyline();
            polyline18.Vertexes.Add(new LwPolylineVertex(new Vector2(v69.X + (0.28 / 30.69) * OAL, v69.Y)));
            polyline18.Vertexes.Add(new LwPolylineVertex(new Vector2(v69.X + (0.28 / 30.69) * OAL, v71.Y)));
            fun.PolyFill(dxf, polyline18, 0.3, contour);

            //虚线
            LwPolyline polyline19 = new LwPolyline();
            polyline19.Vertexes.Add(new LwPolylineVertex(v83));
            polyline19.Vertexes.Add(new LwPolylineVertex(v84));
            polyline19.Vertexes.Add(new LwPolylineVertex(v85));
            polyline19.Vertexes.Add(new LwPolylineVertex(v86));
            polyline19.Vertexes.Add(new LwPolylineVertex(v83));
            polyline19.Linetype = Linetype.Dashed;
            polyline19.LinetypeScale = 5;
            polyline19.Layer = refin;
            dxf.AddEntity(polyline19);*/

            //标注---------------------------------------------------------------------------
            double height = 1 * scale;
            double arrowsize = 1 * scale;
            double exline = 0.5 * scale;

            //第一部分
            //坐标系
            /*fun.Axis(dxf, v20, 90, 180, "Y", "Z", "PCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v21, 90, 180, "Y", "Z", "MCS", 0.2 * scale, height * 0.5, 0);*/

            //OAL
            fun.dimrot1(dxf, v1, v17, 0, H * 2, 0.1, height, arrowsize, exline, "OAL", "", "");

            //CDX
            fun.dimrot1(dxf, v2, v17, 0, H, 0.1, height, arrowsize, exline, "CDX", "", "");

            //HF
            fun.dimrot1(dxf, v7, v17, -90, OAL * (9.91 / 30.69), 0.1, height, arrowsize, exline, "HF", "", "");

            //H
            fun.dimrot1(dxf, v1, v8, 90, OAL * (5.02 / 30.69), 0.1, height, arrowsize, exline, "H", "", "");

            //HTA
            /*Line line1 = new Line(v17, new Vector2(v17.X + OAL * (13.72 / 30.69), v17.Y));
            line1.Layer = dimensioning;
            dxf.AddEntity(line1);

            fun.jt1(dxf, new Vector2(v17.X + OAL * (12.76 / 30.69), v17.Y), -90, 5, 0, "HTA", height);
            fun.jt1(dxf, new Vector2(v17.X + OAL * (12.76 / 30.69), v17.Y), 90, 3, 0, "", height);

            fun.text1(dxf, new Vector2(v19.X, v19.Y - (2 / 6.54) * H), 90, "A");
            fun.text1(dxf, new Vector2(v18.X, v18.Y + (2 / 6.54) * H), 90, "A");*/

            //第二部分
            //坐标系
            /*fun.Axis(dxf, v25, 180, 270, "Z", "X", "PCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v32, 180, 270, "Z", "X", "MCS", 0.2 * scale, height * 0.5, 0);*/

            //LPR
            fun.dimrot1(dxf, v32, v24, 180, H * 2, 0.1, height, arrowsize, exline, "LPR", "", "");

            //LF
            fun.dimrot1(dxf, v25, v24, 180, H * 2.5, 0.1, height, arrowsize, exline, "LF", "", "");

            //fun.jt1(dxf, v37, 180, 5, 0, "FDP", height);

            fun.text1(dxf, v38, 90, "C");

            //第三部分
            //坐标系
            /*fun.Axis(dxf, v39, 90, 180, "", "", "PCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v53, 90, 180, "", "", "MCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v52, 90, 180, "Y", "X", "", 0.2 * scale, height * 0.5, 0);

            fun.text1(dxf, v51, 90, "A-A");

            //第四部分
            //坐标系
            fun.Axis(dxf, v59, 90, 180, "Y", "X", "PCS", 0.2 * scale, height * 0.5, 0);

            fun.text1(dxf, v64, 90, "B");

            //第五部分
            //坐标系
            fun.Axis(dxf, v82, 180, 270, "Z", "X", "MCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v88, 90, 180, "Z", "Y", "CSW", 0.2 * scale, height * 0.5, 0);

            //WF
            fun.dimrot1(dxf, v70, v71, -90, OAL * (9.45 / 27.14), 0.1, height, arrowsize, exline, "WF", "", "");

            fun.text1(dxf, v87, 90, "C");*/

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
